Skip to content
This repository has been archived by the owner on Jul 5, 2022. It is now read-only.

Fix bugs when transfer chunked result #37

Merged
merged 1 commit into from
Sep 2, 2021

Conversation

nyanpassu
Copy link
Collaborator

@nyanpassu nyanpassu commented Sep 1, 2021

this PR fix bugs when transfering chunked result

when request is get and response is trunked, http response from dockerd will be write to proxy response and flush right away.

this only applys to get request and chunked response in order to fix /events api, do not invovle other circumstances in order not to involve too many test to catch up with 9.9

utils/utils.go Outdated
return
}
log.Error("[ForwardChunked] can't Hijack ServerResponseWriter")
if err := WriteBadGateWayResponse(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#36

utils/utils.go Outdated
// first we send response to non overrided client, make sure it's ready for new protocol
if err = writeChunkedResponseHeader(
response,
http.StatusSwitchingProtocols,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

为啥要 101, 这个 API 本身就是直接返回 200 吧, barrel proxy 的行为应该是完全透明的吧

utils/utils.go Outdated
log.Errorf("[doForwardChunked] Hijack ServerResponseWriter failed %v", err)
return
}
defer forwardChunked(conn, resp.Body)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

为什么是 defer?

@nyanpassu nyanpassu force-pushed the bugfix/forward-chunked branch from e19b07b to 2ad4f77 Compare September 2, 2021 14:33
@nyanpassu nyanpassu marked this pull request as ready for review September 2, 2021 14:39
@nyanpassu nyanpassu force-pushed the bugfix/forward-chunked branch from 2ad4f77 to d118481 Compare September 2, 2021 14:42
@nyanpassu nyanpassu changed the title [WIP]fix bugs when transfer chunked result Fix bugs when transfer chunked result Sep 2, 2021
@nyanpassu nyanpassu force-pushed the bugfix/forward-chunked branch from d118481 to a565edd Compare September 2, 2021 15:04
Copy link
Member

@jschwinger233 jschwinger233 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

看起来不错, 你自己测过了就好.

@jschwinger233 jschwinger233 merged commit 0c10d66 into projecteru2:master Sep 2, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants